#include "mysqlMgr.h"

mysqlMgr& mysqlMgr::GetInst()
{
	static mysqlMgr instance;
	return instance;
}

std::shared_ptr<UserInfo> mysqlMgr::GetUser(int uid)
{
	return _dao.GetUser(uid);
}

std::shared_ptr<UserInfo> mysqlMgr::GetUser(std::string name)
{
	return _dao.GetUser(name);
}

int mysqlMgr::RegUser(const std::string& name, const std::string& email, const std::string& pwd)
{
	return _dao.RegUser(name, email, pwd);
}

bool mysqlMgr::CheckEmail(const std::string& user, const std::string& email)
{
	return _dao.CheckEmail(user, email);
}

bool mysqlMgr::UpdatePwd(const std::string& name, const std::string& pwd)
{
	return _dao.UpdatePwd(name, pwd);	
}

bool mysqlMgr::AddFriendApply(const int& from, const int& to)
{

	return _dao.AddFriendApply(from, to);
}

bool mysqlMgr::GetApplyList(const int& uid, std::vector<std::shared_ptr<ApplyInfo>>& apply_list, int begin, int limit)
{
	return _dao.GetApplyList(uid, apply_list,0,10);
}

bool mysqlMgr::CheckPwd(const std::string& user, const std::string& pwd,UserInfo& userinfo)
{
	return _dao.CheckPwd(user, pwd,userinfo);
}

bool mysqlMgr::AuthFriendApply(const int& uid, const int& touid)
{
	return _dao.AuthFriendApply(uid, touid);
}

bool mysqlMgr::GetFriendList(const int& self_uid, std::vector<std::shared_ptr<UserInfo>>& user_list)
{
	return _dao.GetFriendList(self_uid,user_list);
}

bool mysqlMgr::AddFriend(const int& uid, const int& touid, const std::string& back_name)
{
	return _dao.AddFriend(uid,touid,back_name);
}

mysqlMgr::mysqlMgr()
{

}
